export const setHtmlSize = () => {
    function setRem () {
      let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
      // console.log(htmlWidth)
      let raito = htmlWidth*0.0047565153733529
      let htmlDom = document.getElementsByTagName('html')[0];
        htmlDom.style.fontSize = htmlWidth / raito + 'px';   
    }
    setRem();
    window.onresize = function () {
      setRem()
    }
}
//防抖
export const debounce=(func, wait)=> {    
  let timeout;    
  return function () {  
        let context = this;       
        let args = arguments; 
           clearTimeout(timeout)        
           timeout = setTimeout(function(){ func.apply(context, args)}, wait);    
  }
}
//节流
export const throttle=(fn, delay)=>{
  let timer = null;
  return function() {
    let context = this;
    let args = arguments;
    if (!timer) {
      timer = setTimeout(function() {
        fn.apply(context, args);
        timer = null;
      }, delay);
    }
  }
}
